1 REM Program:      GETCLOCK
2 REM Author:       Gerald M. Vrooman
3 REM Language:     GWBASIC
4 REM
10 REM GETCLOCK  was written to initialize DOS time and date from a clock
11 REM card using the following port addresses:
12 REM
13 REM               &h242      Second
14 REM               &h243      Minute
15 REM               &h244      Hour
16 REM               &h246      Day
17 REM               &h247      Month
18 REM               &h249      Year
22 REM
23 REM GETCLOCK can be modified for cards using different ports by
24 REM substituting the correct port addresses  in line 60 - 90.
25 REM The following line inserted in the user's AUTOEXEC.BAT file
26 REM will set DOS time and  date when booting up:
27 REM
28 REM           GWBASIC GETCLOCK
29 REM
30 REM
31 REM
32 REM
50 REM read in time and date variables from clock card
60 N = INP(&H242) : GOSUB 500 : SE$ = STR$(DE)
65 N = INP(&H243): GOSUB 500: MI$ = STR$(DE)
70 N = INP(&H244) : GOSUB 500 : HO$ = STR$(DE)
80 N = INP(&H246) : GOSUB 500 : DA$ = STR$(DE)
90 N = INP(&H247) : GOSUB 500 : MO$ = STR$(DE)
95 N = INP(&H249) : GOSUB 500 : YR$ = STR$(DE)
190 REM
200 REM Build strings for TIME$ and DATE$
201 REM
210 TI$ = "00:00:00" : DT$ = "00/00/1900"
220 IF LEN(HO$)=2 THEN MID$(TI$,2,1) = RIGHT$(HO$,1) ELSE MID$(TI$,1,2) = RIGHT$(HO$,2)
230 IF LEN(MI$)=2 THEN MID$(TI$,5,1) = RIGHT$(MI$,1) ELSE MID$(TI$,4,2) = RIGHT$(MI$,2)
240 IF LEN(SE$)=2 THEN MID$(TI$,8,1) = RIGHT$(SE$,1) ELSE MID$(TI$,7,2) = RIGHT$(SE$,2)
250 IF LEN(MO$)=2 THEN MID$(DT$,2,1) = RIGHT$(MO$,1) ELSE MID$(DT$,1,2) = RIGHT$(MO$,2)
260 IF LEN(DA$)=2 THEN MID$(DT$,5,1) = RIGHT$(DA$,1) ELSE MID$(DT$,4,2) = RIGHT$(DA$,2)
265 IF LEN(YR$)=2 THEN MID$(DT$,10,1) = RIGHT$(YR$,1) ELSE MID$(DT$,9,2) = RIGHT$(YR$,2)
275 REM
276 REM Stuff correct time and date  into TIME$ and DATE$
277 REM
290 TIME$ = TI$ : DATE$ = DT$
298 REM
299 REM Exit GWBASIC
300 SYSTEM
499 END
500 REM convert bcd to decimal
510 IF N=0 THEN T%=0 ELSE T%=(N/16) - .5
520 D% = N - (T% * 16)
530 DE = (T%*10) + D%
550 RETURN
